{template header}
<!--main-->
<style>
    .menu a{
        color:black;
        font-weight:normal;
        font-size:10px
    }
    .menu .active{
        font-weight:bold
    }


</style>
<div class="container">


    <div class="row top10">
        <dl>
            <dd>
                <ul>
                    <li>
                        <span style="width: 20%;font-size: 15px"><a href="{tsUrl('duty','chart',array('next'=>$next-1))}"><i class="fa fa-hand-o-left"></i> 上周</a></span>
                        <span style="width: 50%;font-size: 15px;text-align: center">分馆排班一览表</span>
                        <span style="width: 20%;font-size: 15px"><a href="{tsUrl('duty','chart',array('next'=>$next+1))}">下周 <i class="fa fa-hand-o-right"></i></a></span>
                    </li>
                </ul>
                <ul>
                    <li>橙色表示不可排，绿色表示可排，数字表示预约人数；点击色块可以查看预约名单</li>
                </ul>

<!--
           <h3 style="padding:10px;display: flex ">

               <div>
                   <select onChange="MM_jumpMenu('parent',this,0)" style="width: 80px;font-size:10px;font-weight: 300;height: 20px">
                       <option value="{tsUrl('user','list',array('duty'=>$duty,'orgid'=>$orgid,'page'=>$page))}">所有分馆</option>
                       {loop $strGroup $key $item}
                       <option value="{tsUrl('user','list',array('duty'=>$duty,'orgid'=>$orgid,'groupid'=>$item['groupid']))}" {if $groupid==$item['groupid']}selected{/if}>{$item['groupname']}</option>
                       {/loop}
                   </select>
               </div>

               <div style="margin-left: 5px">
                   <select onChange="MM_jumpMenu('parent',this,0)" style="width: 80px;font-size:10px;font-weight: 300;height: 20px">
                       <option value="{tsUrl('user','list',array('duty'=>$duty,'groupid'=>$groupid,'page'=>$page))}">所有组织</option>
                       {loop $strOrg $key $item}
                       <option value="{tsUrl('user','list',array('duty'=>$duty,'groupid'=>$groupid,'orgid'=>$item['orgid'],'page'=>$page))}" {if $orgid==$item['orgid']}selected{/if}>{$item['orgname']}</option>
                       {/loop}
                   </select>
               </div>
               {if isMobile()}
                   <div style="margin-left: 5px">
                       <select onChange="MM_jumpMenu('parent',this,0)" style="width:50px;font-size:10px;font-weight: 300;height: 20px">
                           <option {if $duty==''}selected{/if} value="{SITE_URL}index.php?app=user&ac=list&groupid={$groupid}&orgid={$orgid}">全体</option>
                           <option {if $duty==1}selected{/if} value="{SITE_URL}index.php?app=user&ac=list&duty=1&groupid={$groupid}&orgid={$orgid}">上岗</option>
                           <option {if $duty==2}selected{/if} value="{SITE_URL}index.php?app=user&ac=list&duty=2&groupid={$groupid}&orgid={$orgid}">活跃</option>
                           <option {if $duty==3}selected{/if} value="{SITE_URL}index.php?app=user&ac=list&duty=3&groupid={$groupid}&orgid={$orgid}">潜水</option>
                           <option {if $duty==4}selected{/if} value="{SITE_URL}index.php?app=user&ac=list&duty=4&groupid={$groupid}&orgid={$orgid}">候任</option>
                           <option {if $duty==5}selected{/if} value="{SITE_URL}index.php?app=user&ac=list&duty=5&groupid={$groupid}&orgid={$orgid}">候选</option>
                       </select>
                   </div>
               {else}
               <div class="menu" style="margin-left: 10px;line-height: 20px">
                    <a {if $duty==''}class="active"{/if} href="{SITE_URL}index.php?app=user&ac=list&groupid={$groupid}&orgid={$orgid}">全体</a>  |
                    <a {if $duty==1}class="active"{/if} href="{SITE_URL}index.php?app=user&ac=list&duty=1&groupid={$groupid}&orgid={$orgid}">上岗</a>  |
                    <a {if $duty==2}class="active"{/if} href="{SITE_URL}index.php?app=user&ac=list&duty=2&groupid={$groupid}&orgid={$orgid}">活跃</a>  |
                    <a {if $duty==3}class="active"{/if} href="{SITE_URL}index.php?app=user&ac=list&duty=3&groupid={$groupid}&orgid={$orgid}">潜水</a>  |
                    <a {if $duty==4}class="active"{/if} href="{SITE_URL}index.php?app=user&ac=list&duty=4&groupid={$groupid}&orgid={$orgid}">候任</a>  |
                <a {if $duty==5}class="active"{/if} href="{SITE_URL}index.php?app=user&ac=list&duty=5&groupid={$groupid}&orgid={$orgid}">候选</a>
               </div>

               {/if}

               <small style="margin-left: 5px;line-height: 20px;font-size: 10px">&nbsp;&nbsp;计数：{$userNum}</small>
               {if !isMobile()&$GLOBALS['TS_USER']['isadmin']=='1' }
               <a style="margin-left: 5px;color: black;line-height: 20px;float: right;"  data-toggle="modal" data-target="#do_export_form">导出</a>
               {/if}


    </h3>

-->
    <ul><li>
        <span style="width: 15%">分馆<br>(点击查看)</span>{for $i=0;$i<5;$i++}<span style="width: 13%;height: 30px">{php echo date('ymd',strtotime('+'.$i.' day',$fromday))}<br/>(周{php echo cnWeek(strtotime('+'.$i.' day',$fromday))})</span>{/for}
        </li>
    </ul>
         <ul>
        {loop $arrGroup $key $item}
            <li style="height: 40px" onclick="jump('{tsUrl('duty','order',array('groupid'=>$item['groupid'],'next'=>$next))}')">
           <span style="width: 15%;padding-top: 5px"><a href="{tsUrl('duty','order',array('groupid'=>$item['groupid'],'next'=>$next))}">{$item['groupname']}</span></a></span>
             {for $i=0;$i<5;$i++}
                {php $begintime = $fromday+$i*60*60*24;
                $endtime = $fromday+($i+1)*60*60*24;
                $str = 'groupid='.$item['groupid'].' and begintime>'.$begintime.' and begintime<'.$endtime;
                $stropen = explode(',',$item[openday]);
                $duty = $this->findCount('duty',$str);}
                <span style="width: 13%;height: 35px;padding-top: 7px;color: snow;background-color: {if $begintime>$item[begintime]&&$begintime<$item[endtime]&&in_array($i+1,$stropen)}#83BF73{else} orange{/if}">{if $duty>0}{$duty}{/if}</span>{/for}
            </li>
        {/loop}
        </ul>
                </dd>
            </dl>
        <!--
        <div class="page">{$pageUrl}</div>
        -->
    </div>

</div>


<div id="do_export_form" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true" >
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h5 class="modal-title">筛选范围</h5>
            </div>
            <div class="modal-body" >
                <form  id="open-form" class="form-horizontal" method="post" action="{SITE_URL}index.php?app=user&ac=do&ts=export">

                    <div class="form-group">
                        <label class="col-sm-2 control-label">统计口径</label>
                        <input name="type" type="radio" value="addtime" />加入日期
                        <input name="type" type="radio" value="lasttime" />服务日期
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">起始日期</label>
                        <div class="col-sm-3"><select  data-name="year" name="beginyear" class="form-control"></select></div>
                        <div class="col-sm-3"><select  data-name="month" name="beginmonth" class="form-control"></select></div>
                        <div class="col-sm-3"><select  data-name="day"  name="beginday" class="form-control"></select></div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">截止日期</label>
                        <div class="col-sm-3"><select  data-name="year" name="endyear" class="form-control"></select></div>
                        <div class="col-sm-3"><select  data-name="month" name="endmonth" class="form-control"></select></div>
                        <div class="col-sm-3"><select  data-name="day"  name="endday" class="form-control"></select></div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-offset-2 col-sm-10">
                            <button type="submit" class="btn btn-success">点击提交</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<script>
    $(document).ready(function(e) {
        var date = new Date();
        var vYear = date.getFullYear();
        var vMon = date.getMonth() + 1;
        var vDay = date.getDate();
        var year;
        var month;
        var day;
        var str_year;
        var str_month;
        var t_month;
        var str_day;

        {if $myDuty!=''}
            vYear = {php echo date('Y',$myDuty['begintime'])};
            vMon  = {php echo date('m',$myDuty['begintime'])};
            vDay  = {php echo date('d',$myDuty['begintime'])};
            {/if}

                var first_year = 2017;
//起始
                var last_year = date.getFullYear();
//终止年
                var t_year
                var i;
                var r;
                var y_v;
                var m_v;
                var d_v;
//写出年的选项
                $("[data-name=year]").append('<option value=""></option>');
                for (i = last_year; i >= first_year; i--) {

                    if (i != vYear) {
                        $("[data-name=year]").append('<option value="' + i + '">' + i + '</option>');
                    } else {
                        $("[data-name=year]").append('<option value="' + i + '" selected>' + i + '</option>');
                    }
                }
//写出月的选项
                $("[data-name=month]").append('<option value=""></option>');
                for (i = 1; i <= 12; i++) {
                    r = i ;
                    if (i != vMon) {
                        $("[data-name=month]").append('<option value="' + i + '">' + r + '</option>');
                    } else {
                        $("[data-name=month]").append('<option value="' + i + '" selected>' + r + '</option>');
                    }
                }

//初始化日的值
                day();
//在年月的值发生变化时计算日期的天数
                $("[data-name=year]").change(function(){   day();   });
                $("[data-name=month]").change(function(){ day();
                });
//根据日期的天数，输出日选项

                function day(){
                    var y_v=$("[data-name=year]").val();
                    var m_v=$("[data-name=month]").val()-1;
                    var d_v;
                    var i;
                    if((y_v%100!=0&&y_v%4==0)||y_v%400==0) {
                        d_v=new Array(31,29,31,30,31,30,31,31,30,31,30,31);
                    }    else   {
                        d_v=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
                    }
                    $("[data-name=day]").html("");
                    $("[data-name=day]").append('<option value=""></option>');
                    for(i=1;i<=d_v[m_v];i++)   {
                        //if(i!=vDay)  {
                        $("[data-name=day]").append('<option value="'+i+'">'+i+'</option>');
                        //	}  else {
                        //	$("[data-name=day]").append('<option value="'+i+'" selected>'+i+'</option>');
                        //	}
                    }
                }
            });

</script>




{template footer}